﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for Topic_DAL
/// </summary>
public class Topic_DAL
{
    DataAccess da = new DataAccess();

    public DataTable Get_All_Topic_DAL(){
        return da.executeSelect("SL_Topic");
    }

    public DataTable getALLTopic()
    {
        return da.executeSelect("GET_Topic");
    }

    public int deleteTopic(int topic_id) {
        SqlParameter[] paramList = new SqlParameter[1];
        paramList[0] = da.AddParameter("topic_id",topic_id,SqlDbType.Int,null);
        return da.executeUpdate("UPDATE_Topic",paramList);
    }

    public DataTable getTopicByID(int id) {
        SqlParameter[] paramList = new SqlParameter[1];
        paramList[0] = da.AddParameter("topic_id",id,SqlDbType.Int,null);
        return da.executeSelect("GET_Topic", paramList);
    }

    public int Update_Topic(int topic_id,string topic_name,string topic_des) {
        SqlParameter[] paramList = new SqlParameter[3];
        paramList[0] = da.AddParameter("topic_id", topic_id, SqlDbType.Int, null);
        paramList[1] = da.AddParameter("topic_name", topic_name, SqlDbType.NVarChar, null);
        paramList[2] = da.AddParameter("topic_des", topic_des, SqlDbType.NVarChar, null);
        return da.executeUpdate("UPDATE_Topic", paramList);
    }
}